
function PubCourse() {

}

PubCourse.prototype.initUEditor = function () {
    window.ue = UE.getEditor('editor',{
        'serverUrl':'/ueditor/upload/',
        // 初始化富文本编辑器高度
        'initialFrameHeight':200
    });

};

PubCourse.prototype.listenSubmitEvent = function () {
    var submitBtn = $(".submit-btn");
    submitBtn.click(function () {
        var title = $("#title-input").val();
        var category_id = $("#category-input").val();
        var teacher_id = $("#teacher-input").val();
        var video_url = $("#video-input").val();
        var cover_url = $("#thumbnail-input").val();
        var price = $("#price-input").val();
        var duration = $("#time-input").val();
        var profile = window.ue.getContent();

        xfzajax.post({
            'url':'/cms/pub_course/',
            'data':{
                'title':title,
                'category_id':category_id,
                'teacher_id':teacher_id,
                'video_url':video_url,
                'cover_url':cover_url,
                'price':price,
                'duration':duration,
                'profile':profile
            },
            'success':function (result) {
                if(result['code']===200){
                    console.log("22222222");
                    window.messageBox.showSuccess("恭喜，课程发布成功！");
                    window.location.reload()
                }
            }
        })
    })
};

PubCourse.prototype.run = function () {
    this.initUEditor();
    this.listenSubmitEvent()
};

$(function () {
    var pubCourse = new PubCourse();
    pubCourse.run()
});